/**
 * Copyright (c) 2006-2012 Las Venturas Playground, LVP Mineground
 *
 * This program is free software: you can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.mineground.protect;

import java.util.HashMap;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

/**
 * The lvmProtect plugin provides players with the ability to lock and protect their chests,
 * dispensers, furnaces and doors. They will also be protected for external damage, as can be done
 * by, for example, explosions and weapon damage.
 * 
 * Functionality in this plugin is inspired by LWC, but implemented in a much more isolated fashion.
 */
public class Plugin extends JavaPlugin {
    private static boolean mIsEnabled = true;
    private FocusTracker mFocusTracker;
    private Storage mStorage;
    
    public void onEnable() {
        mStorage = new Storage();
        mFocusTracker = new FocusTracker();
        
        Log.notice("[LVM Protect] Plugin enabled, loading protected objects..");
        Log.notice("[LVM Protect] Loaded %d blocks.", mStorage.loadProtectedBlocksFromDatabase());
        
        // TODO: Add the /cprotect, /cunprotect and whatever other command here.
        
        getServer().getPluginManager().registerEvents(new EventListener(mFocusTracker), this);
    }
    
    @Override
    public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
        // TODO: Handle all the registered commands.
        return false;
    }
    
    public void onDisable() {
        Log.notice("[LVM Protect] Plugin disabled.");
    }
    
    /**
     * The plugin can be enabled and disabled quite easily, making sure that administrators can tune
     * the in-game experience to their liking. Also for performance debugging.
     */
    public static void setPluginEnabled(boolean isEnabled) {
        mIsEnabled = isEnabled;
    }
    
    public static boolean isPluginEnabled() {
        return mIsEnabled;
    }
}
